//
//  Service+Comment.m
//  gskin
//
//  Created by fengyn on 15/12/15.
//  Copyright © 2015年 lexingsoft. All rights reserved.
//

#import "Service+Comment.h"

@implementation ServiceManager(Comment)
///查看评论
+ (void)serviceComment:(NSUInteger)pageIndex string:(NSString *)string success:(void(^)(NSDictionary * data)) success failure:(void(^)()) failure
{
    NSString * path = @"/comment/page";
    const int countPer = 20;
    NSDictionary * dic = @{@"page":@(countPer*pageIndex),
                           @"targetType":@"WORKER",
                           @"targetId":string,
                           @"auditStatus":@"Y"};
    [NetworkClient getRequest:path parameters:dic NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}

///发送评论
+ (void)postCreateComment:(NSString *)NBR commentBody:(NSString *)commentBody orderSn:(NSString *)orderSn success:(void(^)(NSDictionary * data)) success failure:(void(^)()) failure
{
    NSString * path = @"/comment";
    NSDictionary * dict = @{@"targetType":@"WORKER",
                            @"targetSequenceNbr":NBR,
                            @"commentBody": commentBody,
                            @"orderSn":orderSn};
    
    [NetworkClient postRequest:path parameters:dict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}
///根据订单号获取该订单评论
+ (void)getCommentWithOrderSn:(NSString *)orderSn success:(void(^)(NSDictionary * data)) success failure:(void(^)()) failure
{
    NSString * path = @"/comment/ordersn";
    NSDictionary * dic = @{@"orderSn":orderSn};
    [NetworkClient getRequest:path parameters:dic NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}

///根据帖子Id获取评论
+ (void)getCommentWithTargetId:(NSString *)targetId pageIndex:(NSUInteger)pageIndex success:(void(^)(NSDictionary * data)) success failure:(void(^)()) failure;
{
    NSString * path = @"/comment/public";
    const int countPer = 20;
    NSDictionary * dic = @{@"start":@(countPer*pageIndex),
                           @"length":@(countPer),
                           @"targetSequenceNbr":targetId,
                           @"auditStatus":@"Y",
                           @"sidx":@"floor",
                           @"sort":@"asc"};
    [NetworkClient getRequest:path parameters:dic NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}

///对问答进行评论
+ (void)createQuestionrWithtargetId:(NSString *)targetId body:(NSString *)body success:(void(^)(NSDictionary * data)) success failure:(void(^)()) failure
{
    NSString * path = @"/comment";
    NSDictionary * dict = @{
                            @"targetSequenceNbr":targetId,
                            @"commentBody": body,
                            @"targetType":@"QUESTION"
                            };
    
    [NetworkClient postRequest:path parameters:dict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}

///对日记进行评论
+ (void)createDairyrWithtargetId:(NSString *)targetId body:(NSString *)body success:(void(^)(NSDictionary * data)) success failure:(void(^)()) failure
{
    NSString * path = @"/comment";
    NSDictionary * dict = @{
                            @"targetSequenceNbr":targetId,
                            @"commentBody": body,
                            @"targetType":@"DIARY"
                            };
    
    [NetworkClient postRequest:path parameters:dict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];

}


///对帖子进行评论
+ (void)createCommentWithTargetId:(NSString *)targetId body:(NSString *)body success:(void(^)(NSDictionary * data)) success failure:(void(^)()) failure
{
    NSString * path = @"/comment";
    NSDictionary * dict = @{
                            @"targetSequenceNbr":targetId,
                            @"commentBody": body,
                            @"targetType":@"TOPIC"
                            };
    
    [NetworkClient postRequest:path parameters:dict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}

///对学员进行评星
+ (void)createStudentsClassCommentWithOrderSn:(NSString*)orderSn userId:(NSString*)userId workerId:(NSString*)workId courseCode:(NSString *)courseCode starScore:(NSDictionary *)starScore success:(void(^)(NSDictionary * data)) success failure:(void(^)()) failure
{
    
    NSString * path = @"/customablitity";
    NSDictionary * dict = @{@"orderSn":orderSn,
                            @"userId":userId,
                            @"workerId":workId,
                            @"courseCode":courseCode,
                            @"itemAndScore":starScore};
    [NetworkClient postRequest:path parameters:dict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}


@end
